package org.longteng.monitor.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.longteng.monitor.dao.model.TimeStatisticsLog;

import java.util.Date;
import java.util.List;

/**
 * 用时访问统计信息dao，记录各方法运行时间，统计性能
 * @author Hymn
 * @date 2022/12/28
 */
@Mapper
public interface TimeStatisticsLogMapper extends BaseMapper<TimeStatisticsLog> {

    /**
     * 查询最近的性能排序记录
     * @param logDate
     * @return
     */
    @Select("select * from time_statistics_log where log_date >= #{logDate} ORDER BY porceed_times limit #{startIndex},#{pageSize}")
    public List<TimeStatisticsLog> getSortTimeLogs(Date logDate, int startIndex,int pageSize);

    /**
     * 删除已过期较长的统计记录
     * @param logDate
     * @return
     */
    @Delete("delete from time_statistics_log " +
            "    where log_date < #{logDate} ")
    public  int deleteLostLogDateTime(Date logDate);
}